#ifndef _NNSLITE_DATAPAGE_H_
#define _NNSLITE_DATAPAGE_H_

#include "nnsliteglobal.h"


/** nnsliteMemCell */
struct nnsliteMemCell
{
	u8 buf[NNSLITE_CELL_CAPACITY];
	u32 usedsize;
	u32 capacity;
	struct nnsliteMemCell* nextCell;
};

typedef struct nnsliteMemCell nnsliteMemCell;

/** nnsliteDataPage */
struct nnsliteDataPage
{
	nnsliteMemCell* firstCell;
	nnsliteMemCell* lastCell;
	u64 totalusedsize;
	u64 totalcapacity;
	u64 externaddr;
};

typedef struct nnsliteDataPage nnsliteDataPage;

struct nnsliteDataPageCursor
{
	nnsliteMemCell* curCell;
	u32 offsetInCurCell;
};

typedef struct nnsliteDataPageCursor nnsliteDataPageCursor;

NNSLITE_RET nnsliteDataPageInit(nnsliteDataPage* page);
NNSLITE_RET nnsliteDataPageFree(nnsliteDataPage* page);
NNSLITE_RET nnsliteDataPageWrite(nnsliteDataPage* page, const void* buf, u32 bufsize);
NNSLITE_RET nnsliteDataPageWriteObj(nnsliteDataPage* page, const nnsliteObject* object);
NNSLITE_RET nnsliteDataPageCreateCursor(nnsliteDataPage* page, nnsliteDataPageCursor* cur);
NNSLITE_RET nnsliteDataPageRead(nnsliteDataPageCursor* cur, void* buf, u32 bufsize);
NNSLITE_RET nnsliteDataPageCursorIsEnd(nnsliteDataPageCursor* cur);
NNSLITE_RET nnsliteDataPageNextObject(nnsliteDataPageCursor* cur, nnsliteObject* object);
NNSLITE_RET nnsliteDataPageWriteTo(nnsliteDataPage* page, FILE* fp);
NNSLITE_RET nnsliteDataPageReadFrom(nnsliteDataPage* page, FILE* fp);





#endif
